package concurrent.copyOnWrite;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class CopyOnWriteArrayListDemo {

    public static void main(String[] args) {
        List<Integer> list = new CopyOnWriteArrayList<Integer>() {
        };
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.set(2,4);
        list.remove(1);
        list.get(2);
        int i = 4  ;
        for (Integer integer : list) {
            list.add(i++);
            System.out.println(list.toString());
        }
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
        }
    }
}
